// import moment from 'moment/moment';
// import Vue from 'vue'
//
// Vue.filter('moment', function (value, formatString) {
//   if (value == undefined) {
//     return '-';
//   }
//
//   formatString = formatString || 'YYYY-MM-DD HH:mm';
//   return moment(value).format(formatString); // value可以是普通日期 20170723
//   // return moment.unix(value).format(formatString); // 这是时间戳转时间
// });

// 格式化时间，如果接收的ti参数是字符串类型
export const timestrformat = (t1, spe) => {
  spe = spe || "-";
  const time = new Date(t1);
  let year = time.getFullYear();
  let month = time.getMonth();
  month = month < 10 ? "0" + month : month;
  let day = time.getDate();
  day = day < 10 ? "0" + day : day;
  return year + spe + month + spe + day;
};
// 格式化时间,接收的time是Date格式
export const timeformat = (time, spe) => {
  spe = spe || "-";
  let year = time.getFullYear();
  let month = time.getMonth();
  month = month < 10 ? "0" + month : month;
  let day = time.getDate();
  day = day < 10 ? "0" + day : day;
  return year + spe + month + spe + day;
};

// 日期格式化
export function intformate(val, len) {
  if (val == null || val === '') {
    return '-'
  }
  if (len == null) {
    len = 8
  }
  let s = val.toFixed(0).toString()
  let zero = ''
  for (let i = s.length; i < len; i++) {
    zero += '0'
  }
  return zero + s
}
